package com.ruoyi.web.controller.broadcast;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.broadcast.domain.GbssHistory;
import com.ruoyi.broadcast.service.IGbssHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广播历史Controller
 * 
 * @author hcc
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/control/history")
public class GbssHistoryController extends BaseController
{
    @Autowired
    private IGbssHistoryService gbssHistoryService;

    /**
     * 查询广播历史列表
     */
    @PreAuthorize("@ss.hasPermi('control:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(GbssHistory gbssHistory)
    {
        startPage();
        List<GbssHistory> list = gbssHistoryService.selectGbssHistoryList(gbssHistory);
        return getDataTable(list);
    }

    /**
     * 导出广播历史列表
     */
    @PreAuthorize("@ss.hasPermi('control:history:export')")
    @Log(title = "广播历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GbssHistory gbssHistory)
    {
        List<GbssHistory> list = gbssHistoryService.selectGbssHistoryList(gbssHistory);
        ExcelUtil<GbssHistory> util = new ExcelUtil<GbssHistory>(GbssHistory.class);
        util.exportExcel(response, list, "广播历史数据");
    }

    /**
     * 获取广播历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:history:query')")
    @GetMapping(value = "/{broadcastRealId}")
    public AjaxResult getInfo(@PathVariable("broadcastRealId") String broadcastRealId)
    {
        return success(gbssHistoryService.selectGbssHistoryByBroadcastRealId(broadcastRealId));
    }

    /**
     * 新增广播历史
     */
    @PreAuthorize("@ss.hasPermi('control:history:add')")
    @Log(title = "广播历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GbssHistory gbssHistory)
    {
        return toAjax(gbssHistoryService.insertGbssHistory(gbssHistory));
    }

    /**
     * 修改广播历史
     */
    @PreAuthorize("@ss.hasPermi('control:history:edit')")
    @Log(title = "广播历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GbssHistory gbssHistory)
    {
        return toAjax(gbssHistoryService.updateGbssHistory(gbssHistory));
    }

    /**
     * 删除广播历史
     */
    @PreAuthorize("@ss.hasPermi('control:history:remove')")
    @Log(title = "广播历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{broadcastRealIds}")
    public AjaxResult remove(@PathVariable String[] broadcastRealIds)
    {
        return toAjax(gbssHistoryService.deleteGbssHistoryByBroadcastRealIds(broadcastRealIds));
    }
}
